package csel.model.entity;

import csel.model.GameGlobals;
import csel.model.items.EquippableItem;
import csel.model.items.TakeableItem;
import csel.model.items.UseableItem;

public abstract class NonPlayerCharacter extends Character
{
	/**
	 * 
	 */
	private boolean hasDied = false;
	private static final long serialVersionUID = 5L;
	ArtificialIntelligence ai;
	String dialogue;

	NonPlayerCharacter(Occupation occupation, String name, String dialogue)
	{
		super(occupation, name);
		ai = new PeacefulAi();
		this.dialogue = dialogue;
	}


	@Override
	public void dieAction()
	{
		hasDied = true;
		getGameGlobals().getChronoTrigger().removeTicked(ai);
		System.out.println("Tait is dying.......");
		getTile().clearEntity();
	}

	public abstract int getBuyPrice(Character c, TakeableItem ti);

	public abstract int getSellPrice(Character c, TakeableItem ti);

	public String getDialogue()
	{
		return dialogue;
	}



	@Override
	public void die()
	{
		dieAction();
	}

	@Override
	public void pissTaitOff(Character c)
	{
		if(!hasDied)
		{
			getGameGlobals().getChronoTrigger().removeTicked(ai);
			ai = new AngryAi(c, this);
			getGameGlobals().getChronoTrigger().addTicked(ai);
		}
	}

	public void calmTaitDown()
	{
		if(!hasDied)
		{
			getGameGlobals().getChronoTrigger().removeTicked(ai);
			ai = new PeacefulAi();
			getGameGlobals().getChronoTrigger().addTicked(ai);
		}
	}

	@Override
	public void touch(Entity e)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public boolean touch(UseableItem ui)
	{
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean touch(EquippableItem ei)
	{
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public void attach(GameGlobals g)
	{
		super.attach(g);
		g.getChronoTrigger().addTicked(ai);
	}
}
